﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Dropthings.Widget.Framework;
using Dropthings.Widget.Widgets;
using Dropthings.Widget.Widgets.FusionCharts;

public partial class Widgets_FusionChart_Pie2DWidget : System.Web.UI.UserControl, IWidget
{
    #region Fields

    private IWidgetHost _Host;

    #endregion Fields

    #region Methods

    void IEventListener.AcceptEvent(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }

    void IWidget.Closed()
    {
    }

    void IWidget.Collasped()
    {
    }

    void IWidget.Expanded()
    {
    }

    void IWidget.HideSettings(bool userClicked)
    {
        SettingsPanel.Visible = false;
    }

    void IWidget.Init(IWidgetHost host)
    {
        this._Host = host;
    }

    void IWidget.Maximized()
    {
    }

    void IWidget.Restored()
    {
    }

    void IWidget.ShowSettings(bool userClicked)
    {
        SettingsPanel.Visible = true;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        FusionPieChart pieChart = new FusionPieChart();
        pieChart.caption = "饼图标题";
        pieChart.subCaption = "";
        pieChart.showNames = true;
        pieChart.showPercentageInLabel = true;
        pieChart.showPercentageValues = false;
        string chartHtml = pieChart.CreateSetElement(BuildData(), FusionPieChart.Pie3D, divPieChart.ClientID, "name", "value", "text", "id", "test.aspx?id=", true, 370, 247);
        divPieChart.InnerHtml = chartHtml;
    }

    private DataTable BuildData()
    {
        //DataTable dtChart, string nameField, string valueField, string hoverTextField, string urlField, string urlPrefix, int chartWidth, int chartHeight

        DataTable dtData = new DataTable();

        dtData.Columns.Add("name");
        dtData.Columns.Add("value");
        dtData.Columns.Add("text");
        dtData.Columns.Add("id");

        DataRow drData = null;

        drData = dtData.NewRow();

        drData["name"] = "name51";
        drData["value"] = "51";
        drData["text"] = "text51";
        drData["id"] = "";

        dtData.Rows.Add(drData);


        drData = dtData.NewRow();

        drData["name"] = "name32";
        drData["value"] = "32";
        drData["text"] = "text52";
        drData["id"] = "52";
        dtData.Rows.Add(drData);

        drData = dtData.NewRow();

        drData["name"] = "name69";
        drData["value"] = "69";
        drData["text"] = "text69";
        drData["id"] = "69";
        dtData.Rows.Add(drData);

        drData = dtData.NewRow();

        drData["name"] = "name22";
        drData["value"] = "0";
        drData["text"] = "text22";
        drData["id"] = "22";
        dtData.Rows.Add(drData);

        drData = dtData.NewRow();

        drData["name"] = "name51";
        drData["value"] = "51";
        drData["text"] = "text51";
        drData["id"] = "0";
        dtData.Rows.Add(drData);

        drData = dtData.NewRow();

        drData["name"] = "name202";
        drData["value"] = "202";
        drData["text"] = "text202";
        drData["id"] = "202";
        dtData.Rows.Add(drData);

        return dtData;
    }
    #endregion Methods
}